home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Sound / SmallPlugin3 / myplugin3.c < prev    next >
C/C++ Source or Header  |  2001-06-19  |  20KB  |  642 lines

  1. /* Small Plugin 3 ©2001 Jaca/Dreamolers
  2. ** Clever Amigants Polish Society
  3. ** jacadcaps.tripod.com jacadcaps@poczta.onet.pl
  4. ** Plugin looks best on title bar! it's NOT transparent (it only takes the back
  5. ** color of 0,0 window pixel!!!
  6. */
  7.  
  8. /*                                 Based on                                  */
  9. /*****************************************************************************/
  10. /*                         AmigaAMP Plugin skeleton v1.2                     */
  11. /*                     Written December 1998  by Thomas Wenzel               */
  12. /*               Adapted to work with VBCC by Thomas Jensen Jan 1999         */
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <time.h>
  18. #include <math.h>
  19. #include <linkerfunc.h>
  20.  
  21. #include <exec/types.h>
  22. #include <exec/memory.h>
  23. #include <exec/nodes.h>
  24. #include <proto/exec.h>
  25. #include <proto/dos.h>
  26. #include <proto/intuition.h>
  27. #include <proto/graphics.h>
  28. #include <proto/cybergraphics.h>
  29. #include <proto/icon.h>
  30. #include <workbench/startup.h>
  31.  
  32. #include <dos/dostags.h>
  33. #include <dos/dosextens.h>
  34. #include <graphics/gfxbase.h>
  35. #include <exec/tasks.h>
  36. #include <intuition/screens.h>
  37. #include <graphics/rastport.h>
  38.  
  39. #include <cybergraphics/cybergraphics.h>
  40. #include <wbstartup.h>
  41.  
  42. #include "trackinfo.h"
  43.  
  44. #define VERSTR "$VER: SmallPlugin3 1.2 (18.06.01) ©2001 Jaca/Dreamolers-CAPS"
  45.  
  46. static struct WBStartup *wbmsg;
  47. struct GfxBase *GfxBase=0;
  48. struct Library *CyberGfxBase=0;
  49. ULONG scrx=425,scry=2,realdepth;
  50. static struct Screen *wbscr=0;
  51.  
  52. ULONG *background=0,*mixbackground=0,*renderarray=0;
  53. UBYTE fadespeed=4,framespeed=0,randomfreq=20,rfreq=0;
  54. struct Window *wind=0;
  55. BOOL fromwb=FALSE,randomdirection=FALSE;
  56. BYTE direction=3,udirection=1;
  57.  
  58. int main(int a,char**b);
  59. BOOL PluginInit(void);
  60. void PluginExit(void);
  61. void PluginLoop(void);
  62. void DoLines(void);
  63. void MoveLine(UBYTE yposition);
  64. void FillLine(UBYTE yposition);
  65.  
  66. void ShowRequester(char *Text, char *Button);
  67.  
  68. /***************************************************************************/
  69. /* This is the global variables section. Don't change anything here unless */
  70. /* you know what you're doing!                                             */
  71. /***************************************************************************/
  72.  
  73. BYTE             PluginSignal;
  74. ULONG            PluginMask;
  75. BOOL             Accepted;
  76. struct Process   *PluginTask;
  77. struct MsgPort   *PluginMP;
  78. struct MsgPort   *PluginRP;
  79. BYTE             InfoSignal; // v1.2
  80. ULONG            InfoMask;   // v1.2
  81. struct TrackInfo *tinfo;     // v1.2
  82.  
  83. UWORD    *PluginRawL;
  84. UWORD    *PluginRawR;
  85. UWORD    *SpecRawL;
  86. UWORD    *SpecRawR;
  87.  
  88. struct PluginMessage {
  89.     struct Message msg;
  90.     ULONG          PluginMask;
  91.     struct Process *PluginTask;
  92.     UWORD          **SpecRawL;
  93.     UWORD          **SpecRawR;
  94.     BOOL           Accepted;
  95.  
  96.     /* All data beyond this point is new for v1.2.                         */
  97.     /* AmigaAMP v2.5 and up will detect this new data and act accordingly. */
  98.     /* Older versions of AmigaAMP will simply ignore it.                   */
  99.  
  100.     ULONG            InfoMask;
  101.     struct TrackInfo **tinfo;
  102.     ULONG            reserved;
  103. };
  104.  
  105. /***************************************************************************/
  106. /* This is the main part. Again, don't change anything here if you haven't */
  107. /* got a very good reason to do so!                                        */
  108. /***************************************************************************/
  109.  
  110. int main(int a,char**b) {
  111.     struct PluginMessage *PluginMsg;
  112.     struct PluginMessage *ReplyMsg;
  113.  
  114.     /* (TJ) added for VBCC compatibility */
  115.     #ifndef __SASC
  116.     IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 36);
  117.     if(IntuitionBase == NULL) {
  118.         printf("Unable to open intuition.library V36+ (OS 2.1 required)\n");
  119.         exit(5);
  120.     }
  121.     #endif
  122.  
  123.     /* Allocate all user resources */
  124.     if(PluginInit()) {
  125.         /* Check if a plugin capable instance of AmigaAMP is running */
  126.         if(PluginMP=FindPort("AmigaAMP plugin port"))    {
  127.             /* Allocate a sigbit for receiving signals FROM AmigaAMP */
  128.             PluginTask   = (struct Process *)FindTask(NULL);
  129.             PluginSignal = AllocSignal(-1);
  130.             InfoSignal   = AllocSignal(-1);              // v1.2
  131.             if(PluginSignal != -1 && InfoSignal != -1) { // v1.2
  132.                 InfoMask   = 1L << InfoSignal;             // v1.2
  133.                 PluginMask = 1L << PluginSignal;
  134.  
  135.                 /* Allocate a message and reply port for sending messages TO AmigaAMP */
  136.                 PluginMsg=AllocVec(sizeof(struct PluginMessage), MEMF_PUBLIC|MEMF_CLEAR);
  137.                 PluginRP=CreatePort(0,0);
  138.  
  139.                 /* Tell AmigaAMP all the details it needs to know */
  140.                 PluginMsg->msg.mn_Node.ln_Type = NT_MESSAGE;
  141.                 PluginMsg->msg.mn_Length       = sizeof(struct PluginMessage);
  142.                 PluginMsg->msg.mn_ReplyPort    = PluginRP;
  143.                 PluginMsg->PluginMask          = PluginMask;
  144.                 PluginMsg->PluginTask          = PluginTask;
  145.                 PluginMsg->SpecRawL            = &SpecRawL;
  146.                 PluginMsg->SpecRawR            = &SpecRawR;
  147.                 PluginMsg->InfoMask            = InfoMask;  // v1.2
  148.                 PluginMsg->tinfo               = &tinfo;    // v1.2
  149.                 PluginMsg->reserved            = 0;         // v1.2
  150.                 PutMsg(PluginMP, (struct Message *)PluginMsg);
  151.                 /* Wait for a reply */
  152.                 WaitPort(PluginRP);
  153.                 /* Let's see if AmigaAMP accepted our registration attempt */
  154.                 if(ReplyMsg = (struct PluginMessage *)GetMsg(PluginRP)) Accepted=ReplyMsg->Accepted;
  155.                 else Accepted=FALSE;
  156.  
  157.                 if(Accepted) {
  158.                     /* If it did, start the plugin loop */
  159.                     PluginLoop();
  160.  
  161.                     /* Tell AmigaAMP that this plugin is going down */
  162.                     PluginMsg->PluginMask          = 0;        /* (TJ) changed from NULL for VBCC compatibility */
  163.                     PluginMsg->PluginTask          = NULL;
  164.                     PluginMsg->SpecRawL            = NULL;
  165.                     PluginMsg->SpecRawR            = NULL;
  166.                     PluginMsg->InfoMask            = 0;     // v1.2
  167.                     PluginMsg->tinfo               = NULL;  // v1.2
  168.                     PluginMsg->reserved            = 0;     // v1.2
  169.                     PutMsg(PluginMP, (struct Message *)PluginMsg);
  170.                     /* Wait for confirmation before going on! */
  171.                     WaitPort(PluginRP);
  172.                     GetMsg(PluginRP);
  173.                     /* Now that AmigaAMP knows that we're gone, we can quit */
  174.                 }
  175.                 else {
  176.                     /* If AmigaAMP didn't accept us, tell the user about it */
  177.                     ShowRequester("Plugin rejected by AmigaAMP!\nPerhaps there's another one running.", "Abort");
  178.                 }
  179.  
  180.                 /* Free all resources */
  181.                 FreeVec(PluginMsg);
  182.                 DeletePort(PluginRP);
  183.                 if(PluginSignal != -1) FreeSignal(PluginSignal);
  184.                 if(InfoSignal   != -1) FreeSignal(InfoSignal);   // v1.2
  185.             }
  186.             else {
  187.                 ShowRequester("Signal allocation failure!", "Abort");
  188.             }
  189.         }
  190.         else {
  191.             ShowRequester("Could not find message port!\nAmigaAMP probably not running.", "Abort");
  192.         }
  193.     }
  194.     else {
  195.         ShowRequester("Plugin initialisation failed!", "Ok");
  196.     }
  197.     /* Free all user resources */
  198.     PluginExit();
  199.  
  200.     /* added for VBCC compatibility */
  201.     #ifndef __SASC
  202.     if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
  203.     #endif
  204.     return(0);
  205. }
  206.  
  207. /*****************************************************************************/
  208. /* Ok, now for the individual plugin sourcecode.                             */
  209. /* Just like before, we start with the global variables section              */
  210. /*****************************************************************************/
  211.  
  212.  
  213.  
  214. /****************************************************************************/
  215. /* This function will be called once when the plugin is started. You should */
  216. /* allocate all needed resources here. Return TRUE if all went well.        */
  217. /****************************************************************************/
  218.  
  219. BOOL PluginInit(void) {
  220.     /* Initialise everything here. Return TRUE if all went well, FALSE otherwise */
  221. BOOL rc=TRUE;
  222. static struct Library *IconBase;
  223. static struct DiskObject *icon;
  224. static struct Process *prog;
  225. static struct Screen scr;
  226. static struct RastPort *rp;
  227. static struct CommandLineInterface *cli;
  228. static struct DrawInfo *di=0;
  229. char *val,*name;
  230.  
  231.     prog = (struct Process *)FindTask(0);
  232.     cli = BADDR(prog->pr_CLI);
  233.     name = BADDR(cli->cli_CommandName);
  234.     name++;
  235.  
  236.     if ((IconBase = OpenLibrary("icon.library",0)))
  237.     {
  238.         if (fromwb)
  239.         {
  240.             CurrentDir(wbmsg->sm_ArgList[0].wa_Lock);
  241.             icon = GetDiskObject(wbmsg->sm_ArgList[0].wa_Name);
  242.         } else {
  243.         icon = GetDiskObject(name)}
  244.         if (icon)
  245.         {
  246.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"XPOS")))
  247.             {
  248.                 scrx = strtol(val,0,0);
  249.             }
  250.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"YPOS")))
  251.             {
  252.                 scry = strtol(val,0,0);
  253.             }
  254.             
  255.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"FADESPEED")))
  256.             {
  257.                 fadespeed = strtol(val,0,0);
  258.                 if (fadespeed < 1) fadespeed=1;
  259.                 if (fadespeed > 10) fadespeed=10;
  260.             }
  261.  
  262.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"FRAMESKIP")))
  263.             {
  264.                 framespeed = strtol(val,0,0);
  265.                 if (framespeed < 0) framespeed=0;
  266.                 if (framespeed > 6) framespeed=6;
  267.         
  268.             }
  269.  
  270.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"YDIRECTION")))
  271.             {
  272.                 udirection = strtol(val,0,0);
  273.                 if (udirection > 1) udirection=1;
  274.                 if (udirection < -1) udirection=-1;
  275.             }
  276.  
  277.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"XDIRECTION")))
  278.             {
  279.                 direction = (strtol(val,0,0)*3);
  280.                 if (direction > 3) direction=3;
  281.                 if (direction < -3) direction=-3;
  282.  
  283.             }
  284.  
  285.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"RANDOMXDIRECTION")))
  286.             {
  287.                 randomdirection = TRUE;
  288.                 udirection=1;
  289.             }
  290.  
  291.             if ((val = FindToolType((STRPTR *) icon->do_ToolTypes,"RANDOMFREQ")))
  292.             {
  293.                 randomfreq = strtol(val,0,0);
  294.                 if (randomfreq <0) randomfreq=0;
  295.                 if (randomfreq >50) randomfreq=50;
  296.             }
  297.  
  298.             FreeDiskObject(icon);
  299.         }
  300.     }
  301.  
  302.     if (IconBase) CloseLibrary(IconBase);
  303.  
  304.     if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0))) rc=FALSE;
  305.     if (!(CyberGfxBase = (struct Library *)OpenLibrary("cybergraphics.library",41))) rc=FALSE;
  306.  
  307.     if (!(background = AllocVec(100*10*3,MEMF_PUBLIC+MEMF_CLEAR))) rc=FALSE;
  308.     if (!(mixbackground = AllocVec(100*10*3,MEMF_PUBLIC+MEMF_CLEAR))) rc=FALSE;
  309.     if (!(renderarray = AllocVec(100*10*3,MEMF_PUBLIC+MEMF_CLEAR))) rc=FALSE;
  310.  
  311.     if (rc == FALSE) return(FALSE); //MUST BE PLACED HERE!
  312.  
  313.     Delay(5); //wait 1/10 sec for quit of last plugin :)
  314.  
  315.     if ((wbscr=LockPubScreen(0)))
  316.     {
  317.         rp = &wbscr->RastPort;
  318.  
  319.         ReadPixelArray(background,0,0,300,rp,
  320.         scrx,scry,100,10,RECTFMT_RGB); //get background
  321.  
  322.     realdepth=0;
  323.         
  324.         if (IsCyberModeID(GetVPModeID(&wbscr->ViewPort)))
  325.         {
  326.             realdepth = GetBitMapAttr(wbscr->RastPort.BitMap, BMA_DEPTH );
  327.         }
  328.     
  329.         if (realdepth>8)
  330.         {
  331.             if (!(wind = OpenWindowTags(0,WA_Left,scrx,
  332.                                                 WA_Top,scry,
  333.                                                 WA_Width,100,WA_Height,10,
  334.                                                 WA_SizeGadget,FALSE,WA_DragBar,FALSE,
  335.                                                 WA_DepthGadget,FALSE,WA_CloseGadget,FALSE,
  336.                                                 WA_Backdrop,FALSE,WA_Activate,FALSE,
  337.                                                 WA_RMBTrap,TRUE,WA_PubScreen,wbscr,
  338.                                                 WA_Flags,WFLG_BORDERLESS,WA_IDCMP,IDCMP_VANILLAKEY,
  339.                                                 WA_ScreenTitle,VERSTR,
  340.                                                 TAG_DONE))) rc=FALSE;
  341.         } else {rc=FALSE}
  342.     } else {
  343.         rc=FALSE;
  344.     }
  345.  
  346.     if (rc)
  347.     {
  348.         WritePixelArray(background,0,0,300,wind->RPort,0,0,100,10,RECTFMT_RGB);
  349.         CopyMem(background,renderarray,3*10*100);
  350.         CopyMem(background,mixbackground,3*10*100);
  351.         direction=((RangeRand(3)-1)*3);
  352.     }
  353.     
  354.     return rc;
  355. }
  356.  
  357. /******************************************************************************/
  358. /* This function will be called when the plugin is shut down. You should free */
  359. /* all previously allocated resources here.                                   */
  360. /******************************************************************************/
  361.  
  362. void PluginExit(void) {
  363.     /* Free everything you've allocated before */
  364. if (wind) CloseWindow(wind);
  365. if (renderarray) FreeVec(renderarray);
  366. if (background) FreeVec(background);
  367. if (mixbackground) FreeVec(mixbackground);
  368. if (CyberGfxBase) CloseLibrary(CyberGfxBase);
  369. if (GfxBase) CloseLibrary((struct Library *)GfxBase);
  370. if (wbscr)        UnlockPubScreen(0,wbscr);
  371. }
  372.  
  373. /*******************************************************************************/
  374. /* This is the main Plugin Loop. It will receive a signal matching PluginMask  */
  375. /* each time new spectral data is ready. The data is stored in two arrays,     */
  376. /* UWORD SpecRawL[512] and UWORD SpecRawR[512]. The scale is logarithmic, i.e. */
  377. /* 0 means below -96dB, 65535 means 0dB.                                       */
  378. /* No matter how long it takes until your plugin actually processes the data,  */
  379. /* the memory referenced by the array pointers always remains valid!           */
  380. /*                                                                             */
  381. /* Your plugin loop MUST quit when it receives SIGBREAKF_CTRL_C. If you've     */
  382. /* opened a window you should react to the close gadget as well. For full      */
  383. /* screen plugins I strongly recommend checking the ESC key.                   */
  384. /*******************************************************************************/
  385.  
  386. void PluginLoop(void) {
  387.     ULONG Signals,windowsig;
  388.     struct IntuiMessage *msg;
  389.     char title[200];UBYTE frame=0;
  390.     
  391.     windowsig = 1L << wind->UserPort->mp_SigBit;
  392.  
  393.     strcpy(title,VERSTR);
  394.  
  395.     for(;;) {
  396.  
  397.         /* Wait until there's something to do */
  398.         Signals=Wait(SIGBREAKF_CTRL_C | PluginMask | windowsig); // v1.2
  399.  
  400.         /* Break received -> quit at once! */
  401.         if(Signals & SIGBREAKF_CTRL_C) break;
  402.  
  403.  
  404.         if(Signals & windowsig);
  405.         {
  406.             msg = (struct IntuiMessage *)GetMsg(wind->UserPort);
  407.             if (msg)
  408.             {
  409.                 if (msg->Class = IDCMP_VANILLAKEY)
  410.                 {
  411.                     if (msg->Code == 27)
  412.                     {
  413.                         ReplyMsg(&msg->ExecMessage);
  414.                         break;
  415.                     }
  416.                 }
  417.                 ReplyMsg(&msg->ExecMessage);
  418.             }
  419.         }
  420.  
  421.         /* New data has arrived! */
  422.         if(Signals & PluginMask) {
  423.             /*********************************************************/
  424.             /* Visualise SpecRawL[0..511] and SpecRawR[0..512] here! */
  425.             /*********************************************************/
  426.  
  427.                 if (frame == framespeed)
  428.                 {
  429.                     CopyMem(renderarray,mixbackground,3000);
  430.                     if (randomdirection)
  431.                     {
  432.                         if (rfreq == randomfreq)
  433.                         {
  434.                             direction=((RangeRand(3)-1)*3);
  435.                             rfreq=0;
  436.                         }else{
  437.                         rfreq++}
  438.                     }
  439.                     DoLines();
  440.                     WritePixelArray(renderarray,0,0,300,wind->RPort,0,0,100,10,RECTFMT_RGB);
  441.                     frame=0;
  442.                 }else{
  443.                 frame++}
  444.                     
  445.             }
  446.  
  447.         /* New track info has arrived! */
  448. //        if(Signals & InfoMask) {
  449.             /**********************************************************************/
  450.             /* If you want to display anything from struct TrackInfo, do it here! */
  451.             /**********************************************************************/
  452. //                sprintf(title,"ABC-%s",&tinfo->TrackInfoText);
  453. //                SetWindowTitles(wind,0,title);
  454. //        }
  455.     }
  456. }
  457.  
  458.  
  459. void ShowRequester(char *Text, char *Button) {
  460.     struct EasyStruct Req;
  461.  
  462.   Req.es_Title        = "AmigaAMP Plugin";
  463.   Req.es_TextFormat   = (UBYTE*)Text;
  464.   Req.es_GadgetFormat = (UBYTE*)Button;
  465.     EasyRequestArgs(NULL, &Req, NULL, NULL);
  466. }
  467.  
  468. void wbmain(struct WBStartup *msg)
  469. {
  470.     wbmsg = msg;
  471.     if (wbmsg) fromwb = TRUE;
  472.     main(0,0);
  473. }
  474. /* (TJ) added to avoid VBCC linker error */
  475. #ifndef __SASC
  476. struct IntuitionBase *IntuitionBase=NULL;
  477. #endif
  478.  
  479. void DoLines(void)
  480. {
  481.                 MoveLine(0);
  482.                 MoveLine(1);
  483.                 MoveLine(2);
  484.                 MoveLine(3);
  485.                 MoveLine(4);
  486.                 MoveLine(5);
  487.                 MoveLine(6);
  488.                 MoveLine(7);
  489.                 MoveLine(8);
  490.                 MoveLine(9);
  491.                 FillLine(0);
  492.                 FillLine(1);
  493.                 FillLine(2);
  494.                 FillLine(3);
  495.                 FillLine(4);
  496.                 FillLine(5);
  497.                 FillLine(6);
  498.                 FillLine(7);
  499.                 FillLine(8);
  500.                 FillLine(9);
  501.  
  502.  
  503. }
  504.  
  505. void MoveLine(UBYTE yposition)
  506. {
  507. UBYTE *triplet,*triplet2,*triplet3,xcnt;
  508. BYTE cval;
  509.  
  510.     triplet = (UBYTE *)renderarray + (300*yposition);
  511.     triplet2= (UBYTE *)mixbackground + (300*(yposition+1)) + direction;
  512.     switch (yposition)
  513.     {
  514.         case 0:
  515.             triplet2= (UBYTE *)mixbackground + 300;break;
  516.         case 1:
  517.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection)) +direction;break;
  518.         case 2:
  519.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection));break;
  520.         case 3:
  521.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection)) +direction;break;
  522.         case 4:
  523.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection));break;
  524.         case 5:
  525.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection)) +direction;break;
  526.         case 6:
  527.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection));break;
  528.         case 7:
  529.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection)) +direction;break;
  530.         case 8:
  531.             triplet2= (UBYTE *)mixbackground + (300*(yposition+udirection));break;
  532.         case 9:
  533.             triplet2= (UBYTE *)mixbackground + (300*yposition);break;
  534.         
  535.     }
  536.     triplet3= (UBYTE *)background;
  537.  
  538.     for (xcnt = 0; xcnt < 100; xcnt++)
  539.     {
  540.         switch (direction)
  541.         {
  542.             case -3:
  543.                 if (xcnt == 0)
  544.                 {
  545.                     triplet2+=3;
  546.                     cval = (((triplet3[0] - triplet2[0])/fadespeed)+1);
  547.                     if ((cval+triplet2[0]) <= triplet3[0]) {triplet[0]=triplet2[0]+cval}else{triplet[0]=triplet3[0]};
  548.                     cval = (((triplet3[1] - triplet2[1])/fadespeed)+1);
  549.                     if ((cval+triplet2[1]) <= triplet3[1]) {triplet[1]=triplet2[1]+cval}else{triplet[1]=triplet3[1]};
  550.                     cval = (((triplet3[2] - triplet2[2])/fadespeed)+1);
  551.                     if ((cval+triplet2[2]) <= triplet3[2]) {triplet[2]=triplet2[2]+cval}else{triplet[2]=triplet3[2]};
  552.                     triplet+=3;//triplet3+=3;
  553.                 } else {
  554.                     cval = (((triplet3[0] - triplet2[0])/fadespeed)+1);
  555.                     if ((cval+triplet2[0]) <= triplet3[0]) {triplet[0]=triplet2[0]+cval}else{triplet[0]=triplet3[0]};
  556.                     cval = (((triplet3[1] - triplet2[1])/fadespeed)+1);
  557.                     if ((cval+triplet2[1]) <= triplet3[1]) {triplet[1]=triplet2[1]+cval}else{triplet[1]=triplet3[1]};
  558.                     cval = (((triplet3[2] - triplet2[2])/fadespeed)+1);
  559.                     if ((cval+triplet2[2]) <= triplet3[2]) {triplet[2]=triplet2[2]+cval}else{triplet[2]=triplet3[2]};
  560.                     triplet+=3;triplet2+=3;//triplet3+=3;
  561.                 }
  562.                 break;
  563.             case 0:
  564.                     cval = (((triplet3[0] - triplet2[0])/fadespeed)+1);
  565.                     if ((cval+triplet2[0]) <= triplet3[0]) {triplet[0]=triplet2[0]+cval}else{triplet[0]=triplet3[0]};
  566.                     cval = (((triplet3[1] - triplet2[1])/fadespeed)+1);
  567.                     if ((cval+triplet2[1]) <= triplet3[1]) {triplet[1]=triplet2[1]+cval}else{triplet[1]=triplet3[1]};
  568.                     cval = (((triplet3[2] - triplet2[2])/fadespeed)+1);
  569.                     if ((cval+triplet2[2]) <= triplet3[2]) {triplet[2]=triplet2[2]+cval}else{triplet[2]=triplet3[2]};
  570.                     triplet+=3;triplet2+=3;//triplet3+=3;
  571.                 break;
  572.             case 3:
  573.                 if (xcnt == 99)
  574.                 {
  575.                     triplet2-=3;
  576.                     cval = (((triplet3[0] - triplet2[0])/fadespeed)+1);
  577.                     if ((cval+triplet2[0]) <= triplet3[0]) {triplet[0]=triplet2[0]+cval}else{triplet[0]=triplet3[0]};
  578.                     cval = (((triplet3[1] - triplet2[1])/fadespeed)+1);
  579.                     if ((cval+triplet2[1]) <= triplet3[1]) {triplet[1]=triplet2[1]+cval}else{triplet[1]=triplet3[1]};
  580.                     cval = (((triplet3[2] - triplet2[2])/fadespeed)+1);
  581.                     if ((cval+triplet2[2]) <= triplet3[2]) {triplet[2]=triplet2[2]+cval}else{triplet[2]=triplet3[2]};
  582.                 }else{
  583.                     cval = (((triplet3[0] - triplet2[0])/fadespeed)+1);
  584.                     if ((cval+triplet2[0]) <= triplet3[0]) {triplet[0]=triplet2[0]+cval}else{triplet[0]=triplet3[0]};
  585.                     cval = (((triplet3[1] - triplet2[1])/fadespeed)+1);
  586.                     if ((cval+triplet2[1]) <= triplet3[1]) {triplet[1]=triplet2[1]+cval}else{triplet[1]=triplet3[1]};
  587.                     cval = (((triplet3[2] - triplet2[2])/fadespeed)+1);
  588.                     if ((cval+triplet2[2]) <= triplet3[2]) {triplet[2]=triplet2[2]+cval}else{triplet[2]=triplet3[2]};
  589.                     triplet+=3;triplet2+=3;//triplet3+=3;
  590.                 }
  591.                 break;
  592.         }
  593.     }
  594. }
  595.  
  596. void FillLine(UBYTE yposition)
  597. {
  598. ULONG level;
  599. UBYTE *triplet,*triplet2,xcnt;
  600. UBYTE red=0xFF,green=0xFF;
  601.     triplet = (UBYTE *)renderarray + (300*yposition);
  602.     triplet2 = (UBYTE *)background + (300*yposition);
  603.     if (yposition > 0)
  604.     {level = 50000-(yposition*5000);}else{level=50000};
  605.  
  606.     switch (yposition)
  607.     {
  608.         case 1:
  609.             green=0xE0;red=0xF0;break;
  610.         case 2:
  611.             green=0xD0;red=0xF0;break;
  612.         case 3:
  613.             green=0x60;red=0xF0;break;
  614.         case 4:
  615.             green=0x40;red=0xEA;break;
  616.         case 5:
  617.             green=0x20;red=0xD8;break;
  618.         case 6:
  619.             green=0x0;red=0xC6;break;
  620.         case 7:
  621.             red=0xB4;break;
  622.         case 8:
  623.             red=0xA2;break;
  624.         case 9:
  625.             red=0x90;break;
  626.     }
  627.     if (yposition > 6) green=0;
  628.  
  629.     for (xcnt = 0; xcnt < 100; xcnt++)
  630.     {
  631.         if (level <= ((SpecRawL[xcnt*5] + SpecRawR[xcnt*5])/2))
  632.         {
  633.             triplet[0]=red;    //mix color with back
  634.             triplet[1]=green;
  635.             triplet[2]=0;
  636.         }
  637.             triplet+=3;triplet2+=3;
  638.             if (level>200) level-=200 ;
  639.     }
  640. }
  641.  
  642.